//
//  UserLoginViewController.m
//  豆瓣
//
//  Created by aaaaaa on 16/6/25.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "UserLoginViewController.h"
#import "LableAndTextFieldView.h"
#import "UserRegistViewController.h"

@interface UserLoginViewController ()

@end

@implementation UserLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self config];
    
    [self createSubViews];
    
}

- (void)config{
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    self.navigationItem.title = @"用户登陆";
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(backAction:)];
}

- (void)backAction:(UIBarButtonItem *)bar{
    [self.navigationController popToRootViewControllerAnimated:YES];
}


- (void)createSubViews{
    LableAndTextFieldView *userNameLtView = [[LableAndTextFieldView alloc] initWithFrame:CGRectMake(30, 64 + 40, self.view.bounds.size.width - 60, 35)];
    userNameLtView.lableText = @"用户名：";
    userNameLtView.textFieldPlaceholder = @" 请输入用户名";
    [self.view addSubview:userNameLtView];

    LableAndTextFieldView *passWordLtName = [[LableAndTextFieldView alloc] initWithFrame:CGRectMake(30, 64 + 40 + 35 + 20, self.view.bounds.size.width - 60, 35)];
    passWordLtName.lableText = @"密码：";
    passWordLtName.textFieldPlaceholder = @" 请输入密码";
    passWordLtName.encryption = YES;
    [self.view addSubview:passWordLtName];
    
    UIView *buttonView = [[UIView alloc] initWithFrame:CGRectMake(30 + 25, 64 + 40 + 35 * 2 + 20 + 30, self.view.bounds.size.width - 60 - 35, 40)];
    [self.view addSubview:buttonView];
    
    
    UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [loginButton setTitle:@"登陆" forState:UIControlStateNormal];
    loginButton.backgroundColor = [UIColor colorWithRed:0.70f green:0.83f blue:0.41f alpha:1.00f];
    loginButton.frame = CGRectMake(0, 0, buttonView.bounds.size.width * 0.45, buttonView.bounds.size.height);
    loginButton.layer.cornerRadius = 5;
    [loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [loginButton.titleLabel setFont:[UIFont systemFontOfSize:20]];
    [buttonView addSubview:loginButton];
    [loginButton addTarget:self action:@selector(loginAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *registButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [registButton setTitle:@"注册" forState:UIControlStateNormal];
    registButton.backgroundColor = [UIColor colorWithRed:0.89f green:0.58f blue:0.27f alpha:1.00f];
    registButton.frame = CGRectMake(buttonView.bounds.size.width * 0.55, 0, buttonView.bounds.size.width * 0.45, buttonView.bounds.size.height);
    registButton.layer.cornerRadius = 5;
    [registButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [registButton.titleLabel setFont:[UIFont systemFontOfSize:20]];
    [buttonView addSubview:registButton];
    [registButton addTarget:self action:@selector(registAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)loginAction:(UIButton *)button{
    
}

- (void)registAction:(UIButton *)button{
    UserRegistViewController *userRegistVc = [[UserRegistViewController alloc] init];
    [self.navigationController pushViewController:userRegistVc animated:YES];
    [userRegistVc release];
}












- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
